/*
 * @Author: your name
 * @Date: 2021-01-08 14:08:38
 * @LastEditTime: 2022-08-11 15:02:40
 * @LastEditors: Please set LastEditors
 * @Description: 存储空间箭头数据
 * @FilePath: \web_local_rtc\src\assets\arLable\arLable.js
 */
import ARLable from './arLable'
var Arrows = []

/**
 * 清空并返回空数组
 */
function clearArrows () {
  Arrows = []
}

/**
 * 添加箭头点 // 需要处理添加
 * @param {*} pointObj {x1:0,x2:0,y1:0,y2:0}
 * @param {*} WAndHObj {w:0,h:0}
 * @param {*} removeObj {sw:0,sh:0}
 */
function addArrows (pointObj, WAndHObj, removeObj) {
  let o = {
    point: pointObj,
    wh: WAndHObj,
    Rwh: removeObj
  }
  Arrows.push(JSON.parse(JSON.stringify(o)))

  console.log('空间坐标值', Arrows)
}

/**
 * 撤销功能，只撤销当前截图页面上的
 */
function popArrows () {
  Arrows.length ? Arrows.pop() : null
}

/**
 * 返回一个数组
 * [{start:{x;0,y:0},end:{x;0,y:0}}]
 */
function getArrows () {
  let result = dealArrow(Arrows)
  return result
}

export default {
  clearArrows,
  addArrows,
  popArrows,
  getArrows
}



function dealArrow (arrs) {
  let result = []
  arrs.forEach(item => {
    result.push(ARLable.dealARScale(item))
  })
  return result
}



